package com.lingx.web.api.impl;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.lingx.web.api.IApi;
@Component
public class Api9004 extends AbstractDevApi implements IApi{
	@Resource
	private JdbcTemplate jdbcTemplate;

	@Value("#{configs['database.name']}")
	private String table_schema="lingx";
	@Override
	public int getApiCode() {
		return 9004;
	}
	@Override
	public String getApiName() {
		return "获取数据表字段列表";
	}
	@Override
	public Map<String, Object> api(Map<String, Object> param) {
		Map<String,Object> ret=IApi.getRetMap(1, "操作成功");
		String table=param.get("table").toString();
		String sql="SELECT column_name column_name,is_nullable is_nullable,column_type column_type,column_key as column_key1,extra as extra1,column_default column_default,column_comment column_comment from information_schema.columns where table_name= ? and table_schema=? order by ordinal_position asc";//(column_name LIKE ? AND) 

		ret.put("data", this.jdbcTemplate.queryForList(sql,table,table_schema));
		return ret;
	}

	public boolean isLog() {
		return false;
	}
}
